//
//  NSData+Encryption.m
//  YTEncryption
//
//  Created by YaTang on 2017/7/19.
//  Copyright © 2017年 YaTang. All rights reserved.
//

#import "NSData+Encryption.h"
#import "NSString+Encryption.h"

@implementation NSData (Encryption)

- (NSString *)MD5String{
    NSAssert(self, @"data must not be nil!");
    NSString *encryptString = [[NSString alloc] initWithData:self encoding:NSUTF8StringEncoding];
    return [encryptString MD5String];
}

- (NSString *)MD5StringForUppercase{
    return [[self MD5String] uppercaseString];
}

- (NSString *)encryptUseDESWithKey:(NSString *)key{
    NSAssert(self, @"data must not be nil!");
    NSString *encryptString = [[NSString alloc] initWithData:self encoding:NSUTF8StringEncoding];
    return [encryptString encryptUseDESWithKey:key];
}

- (NSString *)decryptUseDESWithKey:(NSString *)key{
    NSAssert(self, @"data must not be nil!");
    NSString *decryptString = [[NSString alloc] initWithData:self encoding:NSUTF8StringEncoding];
    return [decryptString decryptUseDESWithKey:key];
}

@end
